<template>
	<view>
		<view class="inputRow">
		    <View>账号</View>
		    <input type="text" v-model="userName" placeholder="请输入账号" 
		    class="phone_number"></input>
		  </view>
		  <view class="inputRow1">
		    <View>密码</View>
		    <input type="text" password v-model="userPass" 
		    placeholder="请输入密码" class="phone_number"></input>
		  </view>
		  <button class="buttonStyle" type="primary" @click="login">登录</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userName:"",
				userPass:"",
				zcuserName:"",
				zcuserPass:""
			}
		},
		onShow() {
			uni.getStorage({
				key: 'zcuserName',
				
			}).then((res)=>{
				this.zcuserName=res.data
			});
			uni.getStorage({
				key: 'zcuserPass',
				
			}).then((res)=>{
				this.zcuserPass=res.data
			});
		},
		methods: {
			login() {
				
			    if (this.userName === this.zcuserName && this.userPass === this.zcuserPass) {
			      uni.switchTab({
			        url: '/pages/bookshelf/bookshelf',
			        success: function(res) {
			          
			        },
			        fail: function(res) {
			          console.log(res)
			        },
			        
			      })
			      uni.setStorage({
					  key: 'userName',
					  data: this.userName,
			        
			      })
				  uni.setStorage({
					  key: 'pic',
					  data: "https://ts1.cn.mm.bing.net/th?id=OIP-C.dc-NGA0emtrhYtWlzHHbwQHaHa&w=249&h=249&c=8&rs=1&qlt=90&o=6&dpr=1.4&pid=3.1&rm=2",
				  })
			    } else {
			      uni.showToast({
			        title: '账号密码错误',
			        icon: 'none',
			      })
			    }
			  },
		}
	}
</script>

<style>
.inputRow{
    margin-top: 50rpx;
    display: flex;
    flex-direction: row;
    padding-bottom: 20rpx;
    
  }
  .inputRow1{
    margin-top: 50rpx;
    display: flex;
    flex-direction: row;
    padding-bottom: 20rpx;
    
  }
  .phone_number{
    margin-left:40rpx;
    border: 1px solid #eee;
  }
 
.buttonStyle{
    margin-top: 50rpx;
  }
  
</style>
